﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://wubiyu.cnblogs.com">
<head>
      <title></title>
      <link href="../../Theme/DomExtGray/gray.min.css" rel="Stylesheet" type="text/css" />
      <link href="PageModel.css" rel="Stylesheet" type="text/css" />
      <script type="text/javascript" src="../../domExt.min.js"></script>
</head>
<body>
      <div class="fun_title">
            _h.deleteEvent(element, eventName, fn, useCapture);
      </div>
      <div class="fun_content">
            描述：通用事件卸载器。为DOM对象删除事件<br />
      </div>
      <div class="fun_title2">
            参数:
      </div>
      <div class="fun_content2">
           element：dom 对象<br />
           eventName：事件名称(去掉前的on字符)，如:"click"。<br />
            fn：事件回调函数<br />
            useCapture：Boolean(default = false)确定侦听器是运行于捕获阶段、目标阶段还是冒泡阶段。 <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            如果将 useCapture 设置为 true，则侦听器只在捕获阶段处理事件，而不在目标或冒泡阶段处理事件。  
            <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果 useCapture 为 false，则侦听器只在目标或冒泡阶段处理事件。<br />
            <strong>Retrun:</strong><br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            成功返回 true 失败返回 false<br /><br />
      </div>
      <div class="fun_title2">
            示例:
      </div>
      <div class="code">
            &lt;div id=&quot;div1&quot;&gt;&lt;div class=&#39;testclass&#39;&gt;testdiv&lt;/div&gt;&lt;/div&gt;
      </div>
      <input type="hidden" value="<div id='div1'><div class='testclass'>testdiv</div></div>"
            id="htmlcode">
      <div class="code">
            &lt;script type=&quot;text/javascript&quot;&gt;<br />
            &nbsp;&nbsp;&nbsp; function div1_click() { alert(&quot;testdiv&quot;); }
            <br />
&nbsp;&nbsp;&nbsp; function run_click() { var div1 = _g(&quot;#div1&quot;); _h.addEvent(div1, &quot;click&quot;, 
            div1_click); }
            <br />
&nbsp;&nbsp;&nbsp; function run_click2() { var div1 = _g(&quot;#div1&quot;); _h.deleteEvent(div1, 
            &quot;click&quot;, div1_click); }<br />
            &lt;/script&gt;</div>
      <input type="hidden" value=" var div1 = _g('#div1');  var collObjects1=_g('div');var collObjects2=_g('.testclass',div1);alert(div1.innerHTML);"
            id="jscode">
      <br />
      <h:btn onclick="run_click();">绑定事件</h:btn>    <h:btn onclick="run_click2();">解除绑定</h:btn>
      <br />
      <br />
   <div id="div1"><div class='testclass'>testdiv</div></div>
      <script type="text/javascript">
            function div1_click() {
                  alert("testdiv"); 
            }
            function run_click() {
                  var div1 = _g("#div1");
                  _h.addEvent(div1, "click", div1_click);
            }
           
            function run_click2() {
                  var div1 = _g("#div1");
                  _h.deleteEvent(div1, "click", div1_click);
            }
      </script>
</body>
</html>
